package org.rapla.mobile.android.activity;

import java.util.Date;

import org.rapla.entities.domain.Appointment;
import org.rapla.entities.domain.internal.AppointmentImpl;
import org.rapla.mobile.android.R;
import org.rapla.mobile.android.widget.adapter.AppointmentAdapter;

import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.ListView;

/**
 * Appointment List Activity
 * 
 * @author Maximilian Lenkeit <dev@lenki.com>
 */
public class AppointmentListActivity extends BaseActivity {

	private ListView appointmentListView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.appointment_list);

		// Initialize references to view
		appointmentListView = (ListView) findViewById(R.id.appointment_list);
	}

	@Override
	public void onResume() {
		// Retrieve appointsments
		// TODO: Retrieve appointments
		Appointment[] appointments = new Appointment[] {
			new AppointmentImpl(new Date(1323430200l), new Date(1323448200l))	
		};
		
		// Create list adapter for appointments and bind to list view element
		ListAdapter adapter = new AppointmentAdapter(this,
				R.id.appointment_list_item_description, appointments);
		appointmentListView.setAdapter(adapter);
	}
}
